﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using static System.Collections.Specialized.BitVector32;

namespace Ini
{
    public class Ini
    {
        public struct IniFile
        {
            public string FilePath;
            public bool ReadOnly;

            public string IniRead(string section, string keys)
            {
                return dll.INIRead(section, keys, FilePath);
            }

            public void IniWrite(string section, string keys, string value)
            {
                dll.INIWrite(section, keys, value, FilePath);
            }

            public void AddKeys(string section, string keys, string value = "")
            {
                dll.INIWrite(section, keys, value, FilePath);
            }

            public void AddSection(string section)
            {
                StreamWriter sw = File.AppendText(FilePath);
                sw.Write($"\n[{section}]");
                sw.Close();
            }
        }
        public static IniFile OpenIniFile(string path,bool ReadOnly=false)
        {
            if (!File.Exists(path))
            {
                throw new IOException("File Not Exists!");
            }

            IniFile IF = new IniFile();
            IF.FilePath = path;
            IF.ReadOnly = ReadOnly;

            return IF;
        }
    }
}
